<?php
namespace BoxSns\Controller\Home;
//use Think\Controller;

class GroupController extends CommonController {

	public function _initialize() {
		//
		//dump(date("Y-m-d H:i:s",1474437988));
		parent::_initialize();
		$this->nav_cur = "Group";
	}
	//小组首页
	public function index() {
		$this->group_id = I('id', "0", "intval");
		$this->display();
	}
	//小组详情
	public function det() {
		$this->group_id = I('id', "0", "intval");
		$this->cate_id = I('cate_id', "0", "intval");
		$group_info = BoxModel("sns_group")->where(array('id' => $this->group_id))->find();
		$this->web_title = $group_info['group_name'];
		$this->cateList = BoxModel("addon_category")->get(array('type' => "doc_" . $this->group_id), "", "order_by");
		$this->display();
	}
	//发布
	public function edit() {
		$this->group_id = I('group_id');
		if ($this->id = I('id')) {
			$this->data = BoxModel("sns_topic")->load($id);
			$this->group_id = $this->data['pid'];
		}
		$this->cateList = BoxModel("addon_category")->get(array('type' => "doc_" . $this->group_id), "", "order_by");
		//dump($this->cateList);exit();
		$this->display();
	}

	public function topic() {
		$this->topic_id = $id = I('id');
		$data = BoxModel("sns_topic")->load($id);
		$data['wx_content'] = htmlToWxTags($data['content']);
		$this->data = $data;
		BoxModel("sns_topic")->hit_count($this->topic_id);
		$this->group_id = $this->data['pid'];
		$this->display();
	}

	//小组用户
	public function user() {
		$this->group_id = I('group_id');
		$this->groupData = BoxModel("sns_group")->where(array('id' => $this->group_id))->find();
		$this->display();
	}
}